//我的投诉
<template>
  <div class="main">
  
    <div class="div-header">
      <div class="div-left">
        <span class="span-suggest">诉</span>
      </div>
  
      <div class="div-left div-right-width">
        <div class="div-item">
          <div class="head">{{ pageData.SuggstName}}</div>
          <div class="div-suggest-contet">{{pageData.SuggestContent}}</div>
          <div v-for="(item,index) in documents"
               class="div-word"
               @click="displayFile(item.Url)"
               :key="index">
            <img :src="item.Url"
                 class="img-word">
            <span class="span-word">图片{{index+1}}</span>
          </div>
          <div class="div-date">
            <div class="div-left">
              <a class="button-init">业务类</a>
            </div>
            <div class="div-right">{{pageData.SuggestDate}}</div>
            <div class="div-clear"></div>
          </div>
        </div>
        <div class="div-item div-top-solid">
          <div>合作项目:&nbsp;{{ pageData.ProjName}}</div>
          <div>采购过程:&nbsp;{{ pageData.SuggestFj}}</div>
        </div>
        <div class="div-item div-top-solid">
          <div>姓名:&nbsp;{{ pageData.Name}}</div>
          <div>联系电话:&nbsp;{{ pageData.Call}}</div>
          <div>邮件地址:&nbsp;{{ pageData.Email}}</div>
        </div>
      </div>
      <div class="div-clear"></div>
    </div>
  
    <div class="div-bottom">
      <div class="div-left">
        <span class="span-answer">答</span>
      </div>
      <div class="div-left div-right-width"
           v-show="!isAnswer">暂无相关回复</div>
      <div class="div-left div-right-width"
           v-show="isAnswer">
        <div>
          <div class="div-left">答复参见详细文档</div>
          <div class="div-right">{{pageData.ProcessDate}}</div>
          <div class="div-clear"></div>
        </div>
        <!--<div>答疑文档1 .doc</div>-->
      </div>
    </div>
  
    <div v-transfer-dom>
      <x-dialog v-model="isPic"
                class="dialog-demo"
                hide-on-blur>
        <div class="img-box">
          <img :src="picUrl"
               style="max-width:100%">
        </div>
        <div @click="isPic=false">
          <span class="vux-close"></span>
        </div>
      </x-dialog>
    </div>
  </div>
</template>

<script>
import { XDialog, Search, Tab, TabItem, Group, Cell, XButton, dateFormat, Icon, TransferDomDirective as TransferDom } from 'vux'
import { SuggestService } from '../../service/Services.js'

export default {
  name: 'CellBtn',
  directives: {
    TransferDom
  },
  components: {
    XDialog,
    Search,
    Tab,
    TabItem,
    Group,
    Cell,
    XButton,
    Icon
  },
  data () {
    return {
      pageData: {},
      documents: [],
      isAnswer: false,
      isPic: false,
      picUrl: ''
    }
  },
  methods: {
    loadData () {
      this.$vux.loading.show({
        text: '加载中...'
      })
      if (this.$route.query.ReplyState === '已回复') { this.isAnswer = true }
      SuggestService.getMySuggestDetail(this.$route.query.MySuggestGUID).then((res) => {
        this.$vux.loading.hide()
        let item = res.Data[0]
        item.SuggestDate = item.SuggestDate ? this.formatDate(item.SuggestDate) : ''
        item.ProcessDate = item.ProcessDate ? this.formatDate(item.ProcessDate) : ''
        this.pageData = item
        this.documents = res.Documents
      }).catch((res) => {
        this.$vux.toast.show({
          text: '请求失败,请联系管理员',
          type: 'cancel',
          width: '180px'
        })
      })
    },
    formatDate (myDate) {
      var msec = myDate.match(/\d+[+]\d+/gi)
      return dateFormat(new Date(Number.parseInt(msec)), 'YYYY-MM-DD')
    },
    suggest () {
      this.$router.push({ path: '/demos/my-suggest-form' })
    },
    displayFile (url) {
      this.isPic = true
      this.picUrl = url
      // this.$router.push({ path: '/demos/display-file', query: { docUrl: url } })
    }
  },
  mounted () {
    this.loadData()
  }
}
</script>

<style scoped lang='less'>
@import '~vux/src/styles/close';

.dialog-demo {
    .weui-dialog{
    border-radius: 8px;
    padding-bottom: 8px;
  }
  .dialog-title {
    line-height: 30px;
    color: #666;
  }
  .img-box {
    height: 350px;
    overflow: hidden;
  }
  .vux-close {
    margin-top: 8px;
    margin-bottom: 8px;
  }
}
.main {
  word-wrap: break-word;
  font-family: PingFangSC-Regular;
  margin-top: 20px;
}

// body{
// background: #ffffff!important;
// }
.head {
  font-weight: bold;
  font-size: 19px;
  color: #111111;
}

.content {
  margin: 10px 20px 10px 20px;
  font-size: 14px;
  color: #7F7F7F;
  letter-spacing: 0;
  line-height: 30px;
  border-top: 1px solid #E5E5E5;
  padding-top: 10px;
  padding-bottom: 10px;
}

.div-date {
  color: #888888;
}

.div-name {
  margin-left: 20px;
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: bold;
  padding-top: 10px;
}

.div-name span {
  display: inline-block;
  height: 25px;
  width: 4px;
  background: #DC220B;
  position: relative;
  top: 6px;
  margin-right: 10px;
}

.div-item {
  margin-bottom: 10px;
}

.span-suggest {
  background: #62A5F4;
  border-radius: 4px;
  color: #fff;
  display: inline-block;
  font-size: 14px;
  width: 21px;
  height: 21px;
  text-align: center;
  margin: 0 10px 0 20px;
}

.div-left {
  float: left;
}

.div-right {
  float: right;
}

.div-clear {
  clear: both;
}

.span-answer {
  background: #27C86B;
  border-radius: 4px;
  color: #fff;
  display: inline-block;
  font-size: 14px;
  width: 21px;
  height: 21px;
  text-align: center;
  margin: 0 10px 0 20px;
}

.div-header {
  margin-bottom: 10px;
}

.div-bottom {
  // margin-top: 20px;
  border-top: 1px solid #E5E5E5;
  padding-top: 20px;
}

.button-init {
  background-color: white;
  font-size: 12px;
  height: 23px;
  line-height: 23px;
  padding: 0 12px;
  border-radius: 20px;
  display: inline-block;
  border: 1px solid #888888;
}

.div-right-width {
  width: 82%;
}

.div-top-solid {
  padding-top: 10px;
  border-top: 1px solid #E5E5E5;
}

.img-word {
  height: 40px;
  width: 38px;
}

.span-word {
  margin-left: 10px;
  position: relative;
  bottom: 14px;
}

.div-word {
  margin-bottom: 10px;
}
</style>
